package com.project.service;

import com.project.dao.NoticeMapper;
import com.project.dao.PositionTypeMapper;
import com.project.entity.Notice;
import com.project.entity.PositionType;
import com.project.service.base.BaseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by hasee on 2017/4/28.
 */
@Transactional(rollbackFor=Exception.class)
@Service
public class PositionTypeServiceImpl extends BaseService implements PositionTypeService {
    private static PositionTypeMapper positionTypeMapper = null;
    public void setMapper()
    {
        if(positionTypeMapper==null)
            positionTypeMapper = sqlSessionTemplate.getMapper(PositionTypeMapper.class);//1.获取相关mapper
    }
    @Override
    public PositionType findById(int id) {
        setMapper();
        return positionTypeMapper.selectByPrimaryKey(id);
    }

    @Override
    public int update(PositionType positionType) {
        setMapper();
        return positionTypeMapper.updateByPrimaryKeySelective(positionType);
    }

    @Override
    public int addOne(PositionType positionType) {
        setMapper();
        return positionTypeMapper.insertSelective(positionType);
    }

    @Override
    public int delete(int id) {
        setMapper();
        return positionTypeMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<PositionType> findAll() {
        setMapper();
        return positionTypeMapper.selectAll();
    }

    /**
     * author: WheelChen
     * date: 2017/8/2
     * function: 根据学院id批量查找岗位
     *
     * @param schoolId 学院id
     * @return
     */
    @Override
    public List<PositionType> findBatchBySchoolId(Integer schoolId) {
        setMapper();
        return positionTypeMapper.selectBatchBySchoolId(schoolId);
    }

    /**
     * author: WheelChen
     * date: 2017/8/9
     * function: [条件]查找岗位类别
     *
     * @param positionType
     * @return
     */
    @Override
    public List<PositionType> findBatchByCondition(PositionType positionType) {
        setMapper();
        return positionTypeMapper.selectBatchByCondition(positionType);
    }
}
